from datetime import datetime, timedelta

def nowData(year:int = 0,month:int = 0,day:int = 0,hour:int = 0,minute:int=0,second:int = 0):
    # 获取当前日期和时间
    newData = datetime.now()
    if year !=0:
        newData = newData.replace(year=newData.year + year)
    if month !=0:
        # newData = newData.replace(month=newData.month + month)
        # newData = newData + timedelta(days=day * 30)
        newData = newData.replace(month=(newData.month + month) % 12)
        newData = newData.replace(year=newData.year + (newData.month + month) // 12)
    if day != 0:
        # newData = newData.replace(day=newData.day + day)
        newData = newData + timedelta(days=day)
    if hour != 0:
        newData = newData + timedelta(hours=hour)
    if minute != 0:
        newData = newData + timedelta(minutes=minute)

    if second != 0:
        newData = newData + timedelta(seconds=second)
    # 格式化日期和时间
    formatted_datetime = newData.strftime("%Y-%m-%d %H:%M:%S")
    return formatted_datetime

def nowDay(year:int = 0,month:int = 0,day:int = 0,hour:int = 0):
    # 获取当前日期和时间
    newData = datetime.now()
    if year !=0:
        newData = newData.replace(year=newData.year + year)
    if month !=0:
        # newData = newData + timedelta(days=day * 30)
        newData = newData.replace(month=(newData.month + month) % 12)
        newData = newData.replace(year=newData.year + (newData.month + month) // 12)
    if day != 0:
        newData = newData + timedelta(days=day)
    # 格式化日期和时间
    formatted_datetime = newData.strftime("%Y-%m-%d")
    return formatted_datetime
if __name__ == '__main__':
    aa = nowData(minute=-10)
    print(aa)